package com.pica.system.service.impl;

import java.util.List;

import com.pica.system.domain.Resume;
import com.pica.system.mapper.ResumeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pica.system.mapper.EvaluateMapper;
import com.pica.system.domain.Evaluate;
import com.pica.system.service.IEvaluateService;
import com.pica.common.core.text.Convert;

/**
 * 面试评价Service业务层处理
 * 
 * @author 徐鑫杰
 * @date 2022-12-14
 */
@Service
public class EvaluateServiceImpl implements IEvaluateService 
{
    @Autowired
    private EvaluateMapper evaluateMapper;
    @Autowired
    private ResumeMapper resumeMapper;

    /**
     * 查询面试评价
     * 
     * @param evaId 面试评价主键
     * @return 面试评价
     */
    @Override
    public Evaluate selectEvaluateByEvaId(Long evaId)
    {
        return evaluateMapper.selectEvaluateByEvaId(evaId);
    }

    /**
     * 查询面试评价列表
     * 
     * @param evaluate 面试评价
     * @return 面试评价
     */
    @Override
    public List<Evaluate> selectEvaluateList(Evaluate evaluate)
    {
        return evaluateMapper.selectEvaluateList(evaluate);
    }

    /**
     * 新增面试评价
     * 
     * @param evaluate 面试评价
     * @return 结果
     */
    @Override
    public int insertEvaluate(Evaluate evaluate)
    {
        return evaluateMapper.insertEvaluate(evaluate);
    }

    /**
     * 更新面试官的service
     * 
     * @param evaluate 面试评价
     * @return 结果
     */
    @Override
    public int updateEvaluate(Evaluate evaluate)
    {
        Resume resume=new Resume();
        resume.setResId(evaluate.getEvaId());
        if("".equals(evaluate.getUserId1())||null==evaluate.getUserId1()||0==evaluate.getUserId1()){
            resume.setResStatus("20");
        }else {
            if("".equals(evaluate.getEvaTime())||null==evaluate.getEvaTime()){
                //时间为空且面试官1不为null修改简历的状态为确定面试时间
                resume.setResStatus("21");
            }else{
                //修改简历的状态为等待面试反馈
                resume.setResStatus("22");
            }

        }


        resumeMapper.updateResume(resume);
        return evaluateMapper.updateEvaluate(evaluate);
    }


    /**
     * 批量删除面试评价
     * 
     * @param evaIds 需要删除的面试评价主键
     * @return 结果
     */
    @Override
    public int deleteEvaluateByEvaIds(String evaIds)
    {
        return evaluateMapper.deleteEvaluateByEvaIds(Convert.toStrArray(evaIds));
    }

    /**
     * 删除面试评价信息
     * 
     * @param evaId 面试评价主键
     * @return 结果
     */
    @Override
    public int deleteEvaluateByEvaId(Long evaId)
    {
        return evaluateMapper.deleteEvaluateByEvaId(evaId);
    }
}
